package Entity

class MethodEntity {
    /**
     * 成员方法名
     */
    private var name: String = ""
    /**
     * 成员方法返回类型
     */
    private var returnType: String = ""

    /**
     * 成员方法访问类型，默认为public
     */
    private var access:String = "public"

    /**
     * 成员方法参数类型列表，
     */
    private var params: List<String> = ArrayList<String>()

    /**
     * 是否是static变量
     */
    private var isStatic:Boolean = false

    constructor(name: String, returnType: String) {
        this.name = name
        this.returnType = returnType
    }

    constructor(name: String, returnType: String, access: String, params: List<String>, isStatic: Boolean) {
        this.name = name
        this.returnType = returnType
        this.access = access
        this.params = params
        this.isStatic = isStatic
    }

    /**
     * todo：不支持static
     */
    override fun toString():String {
        val sb:StringBuilder = StringBuilder();
        when(access) {
            "private" -> sb.append("-")
            "public" -> sb.append("+")
            else -> sb.append("-")
        }
        sb.append(name)
        sb.append("(")
        if(params.size == 0) {
            sb.append(")")
        } else {
            for (i in 0 until params.size) {
                sb.append(params[i])
                when (i) {
                    params.size - 1 -> sb.append(")")
                    else -> sb.append(", ")
                }
            }
        }
        sb.append(":")
        sb.append(returnType)
        return sb.toString();
    }


}